【记录】JAVA8 Stream()遍历求某列总和 您所在的位置:网站首页 stream string求和 【记录】JAVA8 Stream()遍历求某列总和

【记录】JAVA8 Stream()遍历求某列总和

#【记录】JAVA8 Stream()遍历求某列总和| 来源: 网络整理| 查看: 265

 

List commonList; // 取字段string转int构建新列表List collect = commonList.stream().map(dto -> Integer.valueOf(dto.getCell6())).collect(Collectors.toList()); // reduce求和 Optional reduce = collect.stream().reduce(Integer::sum); Integer total = reduce.get();

 

参考地址

JDK 1.8 新特性之Stream 详解个人笔记:https://blog.csdn.net/chenhao_c_h/article/details/80691284

实现一个LIST集合中的某个元素的求和: https://www.cnblogs.com/jishumonkey/p/12166541.html

Java8对List的求和:https://blog.csdn.net/hsz2568952354/article/details/89886743



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有